<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<table class="easyui-datagrid" id="itemParamList" title="商品列表"
	data-options="singleSelect:false,collapsible:true,pagination:true,url:'/item/param/list',method:'get',pageSize:30,toolbar:itemParamListToolbar">
	<thead>
		<tr>
			<th data-options="field:'ck',checkbox:true"></th>
			<th data-options="field:'id',width:60">ID</th>
			<th data-options="field:'itemCatId',width:80">商品类目ID</th>
			<th data-options="field:'itemCatName',width:100">商品类目</th> 
			<th data-options="field:'paramData',width:300,formatter:formatItemParamData">规格(只显示分组名称)</th>
			<th data-options="field:'created',width:130,align:'center',formatter:JIUSUZU.formatDateTime">创建日期</th>
			<th data-options="field:'updated',width:130,align:'center',formatter:JIUSUZU.formatDateTime">更新日期</th>
		</tr>
	</thead>
</table>
<div id="itemEditWindow" class="easyui-window" title="编辑商品"
	data-options="modal:true,closed:true,iconCls:'icon-save',href:'/item-edit'"
	style="width: 80%; height: 80%; padding: 10px;"></div>
<script>
	function formatItemParamData(value, index) {
		var json = JSON.parse(value);
		var array = [];
		$.each(json, function(i, e) {
			array.push(e.group);
		});
		return array.join(",");
	}

	function getSelectionsIds() {
		var itemList = $("#itemParamList");
		var sels = itemList.datagrid("getSelections");
		var ids = [];
		for ( var i in sels) {
			ids.push(sels[i].id);
		}
		ids = ids.join(",");
		return ids;
	}

	var itemParamListToolbar = [ {
		text : '新增',
		iconCls : 'icon-add',
		handler : function() {
			JIUSUZU.createWindow({
				url : "/item-param-add",
			});
		}
	}, {
		text : '编辑',
		iconCls : 'icon-edit',
		handler : function() {
			$.messager.alert('提示', '该功能未实现!');
		}
	}, {
		text : '删除',
		iconCls : 'icon-cancel',
		handler : function() {
			$.messager.alert('提示', '该功能未实现!');
		}
	} ];
</script>